package com.kstech.mp3604.manager

import com.blankii.androidlibrary.exts.logi

/**
 * 箱子完成逻辑
 */
object StackNumberManager {
    private const val TAG = "StackNumberManager"
    private var mSumStackNumber = 0//需要完成的总箱数
    private var count = 0//已经完成的箱数 完成一次吊起 一次完成
    private lateinit var mListener: ShowDialogConfirmFinished
    fun setListener(listener: ShowDialogConfirmFinished) {
        this.mListener = listener
    }

    fun setSumStackNumber(sum: Int) {
        mSumStackNumber = sum
        count = 0
    }

    fun clear() {
        mSumStackNumber = 0
        count = 0
    }

    fun increaseCount() {
        count++
        "任务总箱数：$mSumStackNumber，已完成箱数：$count".logi(TAG)
        if (count >= mSumStackNumber && mSumStackNumber != 0) {
            mListener.stackNumberIsFinished()
            count = 0
        }
    }

}

interface ShowDialogConfirmFinished {
    fun stackNumberIsFinished()
}